'
' WSC Visual Basic Class  (wscClass.cls)
'
' Requires Visual Basic 5.0 or higher. See ATOK project for an example.
'
' This class is a wrapper for calls to the serial I/O (SIO) functions
' defined in WSC32.BAS, which makes calls to the functions in WSC32.DLL.
'
' The arguments are identical to those in WSC32.BAS, except that string
' results are returned using the ResultString property. The size of the
' maximum result string is set by the 'WorkSize' constant, but can be 
' modified as necessary.
'

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "wscClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'local variable(s) to hold property value(s)

Const WorkSize = 5000
Private WorkBuffer As String * WorkSize
Private WorkLength As Long

Public Function fBaud(ByVal Port As Long, ByVal BaudCode As Long) As Long
fBaud = SioBaud(Port, BaudCode)
End Function

Public Function fBrkSig(ByVal Port As Long, ByVal Cmd As Long) As Long
fBrkSig = SioBrkSig(Port, Cmd)
End Function

Public Function fCTS(ByVal Port As Long) As Long
fCTS = SioCTS(Port)
End Function

Public Function fDCD(ByVal Port As Long) As Long
fDCD = SioDCD(Port)
End Function

Public Function fDone(ByVal Port As Long) As Long
fDone = SioDone(Port)
End Function

Public Function fDSR(ByVal Port As Long) As Long
fDSR = SioDSR(Port)
End Function

Public Function fDTR(ByVal Port As Long, ByVal Char As Long) As Long
fDTR = SioDTR(Port, Char)
End Function

Public Function fEvent(ByVal Port As Long, ByVal Mask As Long)
fEvent = SioEvent(Port, Mask)
End Function

Public Function fFlow(ByVal Port As Long, ByVal Code As Long) As Long
fFlow = SioFlow(Port, Code)
End Function

Public Function fGetc(ByVal Port As Long) As Long
fGetc = SioGetc(Port)
End Function

Public Function fGets(ByVal Port As Long, ByVal BufLen As Long) As Long
Dim Code As Long
' Get string result from "ResultString" property
If BufLen > WorkSize Then
  BufLen = WorkSize
End If
Code = SioGets(Port, WorkBuffer, BufLen)
WorkLength = Code
fGets = Code
End Function

Public Function fInfo(ByVal Cmd As Long) As Long
fInfo = SioInfo(Cmd)
End Function

Public Function fParms(ByVal Port As Long, ByVal Code1 As Long, ByVal Code2 As Long, ByVal Code3 As Long) As Long
fParms = SioParms(Port, Code1, Code2, Code3)
End Function

Public Function fPutc(ByVal Port As Long, ByVal Char As Long) As Long
fPutc = SioPutc(Port, Char)
End Function

Public Function fPuts(ByVal Port As Long, ByVal Buffer As String, ByVal BufLen As Long) As Long
fPuts = SioPuts(Port, Buffer, BufLen)
End Function

Public Function fRead(ByVal Port As Long, ByVal Reg) As Long
fRead = SioRead(Port, Reg)
End Function

Public Function fReset(ByVal Port As Long, ByVal RxQueSize As Long, ByVal TxQueSize As Long) As Long
fReset = SioReset(Port, RxQueSize, TxQueSize)
End Function

Public Function fRI(ByVal Port As Long) As Long
fRI = SioRI(Port)
End Function

Public Function fRTS(ByVal Port As Long, ByVal Char As Long) As Long
fRTS = SioRTS(Port, Char)
End Function

Public Function fRxClear(ByVal Port As Long) As Long
fRxClear = SioRxClear(Port)
End Function

Public Function fRxQue(ByVal Port As Long) As Long
fRxQue = SioRxQue(Port)
End Function

Public Function fStatus(ByVal Port As Long, ByVal Mask As Long) As Long
fStatus = SioStatus(Port, Mask)
End Function

Public Function fTimer() As Long
fTimer = SioTimer()
End Function

Public Function fTxClear(ByVal Port As Long) As Long
fTxClear = SioTxClear(Port)
End Function

Public Function fTxQue(ByVal Port As Long) As Long
fTxQue = SioRxQue(Port)
End Function

Public Function fUnGetc(ByVal Port As Long, ByVal Char As Long) As Long
fUnGetc = SioUnGetc(Port, Char)
End Function

Public Function fWinError(ByVal BufLen As Long) As Long
Dim Code As Long
If BufLen > WorkSize Then
  BufLen = WorkSize
End If
Code = SioWinError(WorkBuffer, BufLen)
WorkLength = Code
fWinError = Code
End Function

Public Property Get ResultString() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.ResultString
    ResultString = Left$(WorkBuffer,WorkLength)
End Property

Private Sub Class_Initialize()
WorkBuffer = ""
WorkLength = 0
End Sub
